#!/usr/bin/env python
#coding=utf8
__author__ = 'chenglin'
import urllib2 , cookielib , urllib
import time



req_header = {'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36',
 'Accept':'*/*',
  'Accept-Charset':'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
  'Accept-Encoding':'gzip, deflate, sdch',
 'Connection':'close',
 'Referer':'http://www.baidu.com'
 }

__username__='18900000001'
__password__='25D55AD283AA400AF464C76D713C07AD'
__loginUrl__='http://localhost:8080/ecp/manage/login!loginManage.do'
__queryCustomerListURL__='http://localhost:8080/ecp/manage/saler!updateSaler_pass.do?'




def postUrl(url):
    # Enable cookie support for urllib2
    cookiejar = cookielib.CookieJar()
    urlOpener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))

    values = {'userDTO.userName':__username__, 'userDTO.pwd':__password__ }
    data = urllib.urlencode(values)

    reqest = urllib2.Request(url, data)
    htmlH = urlOpener.open(reqest)
    respData = htmlH.read(500000)

    respData = respData.decode('utf8')
    print  respData
    return urlOpener;

def login():
   return postUrl(__loginUrl__)
def queryCustomerList(urlOpener):
    url = __queryCustomerListURL__ + 'saler.status=1＇'
    print  url
    urlOpener.open(url)

urlOpener = login()
time.sleep(2)
queryCustomerList(urlOpener)
